//@ts-nocheck
const Palette = (function (t) {
  var e = {};
  function n(r) {
    if (e[r]) return e[r].exports;
    var i = (e[r] = { i: r, l: !1, exports: {} });
    return t[r].call(i.exports, i, i.exports, n), (i.l = !0), i.exports;
  }
  return (
    (n.m = t),
    (n.c = e),
    (n.d = function (t, e, r) {
      n.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: r });
    }),
    (n.r = function (t) {
      "undefined" != typeof Symbol &&
        Symbol.toStringTag &&
        Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }),
        Object.defineProperty(t, "__esModule", { value: !0 });
    }),
    (n.t = function (t, e) {
      if ((1 & e && (t = n(t)), 8 & e)) return t;
      if (4 & e && "object" == typeof t && t && t.__esModule) return t;
      var r = Object.create(null);
      if (
        (n.r(r),
        Object.defineProperty(r, "default", { enumerable: !0, value: t }),
        2 & e && "string" != typeof t)
      )
        for (var i in t)
          n.d(
            r,
            i,
            function (e) {
              return t[e];
            }.bind(null, i)
          );
      return r;
    }),
    (n.n = function (t) {
      var e =
        t && t.__esModule
          ? function () {
              return t.default;
            }
          : function () {
              return t;
            };
      return n.d(e, "a", e), e;
    }),
    (n.o = function (t, e) {
      return Object.prototype.hasOwnProperty.call(t, e);
    }),
    (n.p = ""),
    n((n.s = 0))
  );
})([
  function (t, e, n) {
    t.exports = n(1).default;
  },
  function (t, e, n) {
    "use strict";
    function r(t, e) {
      for (var n = 0; n < e.length; n++) {
        var r = e[n];
        (r.enumerable = r.enumerable || !1),
          (r.configurable = !0),
          "value" in r && (r.writable = !0),
          Object.defineProperty(t, r.key, r);
      }
    }
    n.r(e);
    var i = (function () {
      function t() {
        var e =
            arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [],
          n =
            arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : a;
        if (
          ((function (t, e) {
            if (!(t instanceof e))
              throw new TypeError("Cannot call a class as a function");
          })(this, t),
          (this.data = e),
          (this.length = this.data.length),
          (this.compare = n),
          this.length > 0)
        )
          for (var r = (this.length >> 1) - 1; r >= 0; r--) this._down(r);
      }
      var e, n, i;
      return (
        (e = t),
        (n = [
          {
            key: "push",
            value: function (t) {
              this.data.push(t), this.length++, this._up(this.length - 1);
            },
          },
          {
            key: "pop",
            value: function () {
              if (0 !== this.length) {
                var t = this.data[0],
                  e = this.data.pop();
                return (
                  this.length--,
                  this.length > 0 && ((this.data[0] = e), this._down(0)),
                  t
                );
              }
            },
          },
          {
            key: "peek",
            value: function () {
              return this.data[0];
            },
          },
          {
            key: "_up",
            value: function (t) {
              for (var e = this.data, n = this.compare, r = e[t]; t > 0; ) {
                var i = (t - 1) >> 1,
                  a = e[i];
                if (n(r, a) >= 0) break;
                (e[t] = a), (t = i);
              }
              e[t] = r;
            },
          },
          {
            key: "_down",
            value: function (t) {
              for (
                var e = this.data,
                  n = this.compare,
                  r = this.length >> 1,
                  i = e[t];
                t < r;

              ) {
                var a = 1 + (t << 1),
                  o = e[a],
                  s = a + 1;
                if (
                  (s < this.length && n(e[s], o) < 0 && ((a = s), (o = e[s])),
                  n(o, i) >= 0)
                )
                  break;
                (e[t] = o), (t = a);
              }
              e[t] = i;
            },
          },
        ]) && r(e.prototype, n),
        i && r(e, i),
        t
      );
    })();
    function a(t, e) {
      return t < e ? -1 : t > e ? 1 : 0;
    }
    function o(t) {
      return (t >> 10) & 31;
    }
    function s(t) {
      return (t >> 5) & 31;
    }
    function u(t) {
      return 31 & t;
    }
    function h(t, e, n) {
      (t /= 255), (e /= 255), (n /= 255);
      var r,
        i,
        a = Math.max(t, e, n),
        o = Math.min(t, e, n),
        s = a - o,
        u = (a + o) / 2;
      if (a === o) r = i = 0;
      else {
        switch (a) {
          case t:
            r = ((e - n) / s) % 6;
            break;
          case e:
            r = (n - t) / s + 2;
            break;
          case n:
            r = (t - e) / s + 4;
        }
        i = s / (1 - Math.abs(2 * u - 1));
      }
      return (r = (60 * r) % 360) < 0 && (r += 360), [r, i, u];
    }
    function l(t, e) {
      for (var n = 0; n < e.length; n++) {
        var r = e[n];
        (r.enumerable = r.enumerable || !1),
          (r.configurable = !0),
          "value" in r && (r.writable = !0),
          Object.defineProperty(t, r.key, r);
      }
    }
    var g = (function () {
      function t(e, n, r, i) {
        !(function (t, e) {
          if (!(t instanceof e))
            throw new TypeError("Cannot call a class as a function");
        })(this, t),
          (this.red = e << 3),
          (this.green = n << 3),
          (this.blue = r << 3),
          (this.rgb = (this.red << 16) | (this.green << 8) | this.blue),
          (this.population = i);
      }
      var e, n, r;
      return (
        (e = t),
        (n = [
          {
            key: "getHsl",
            value: function () {
              return (
                null == this.hsl &&
                  (this.hsl = h(this.red, this.green, this.blue)),
                this.hsl
              );
            },
          },
          {
            key: "getRGB",
            value: function () {
              return (
                "rgb(" + this.red + "," + this.green + "," + this.blue + ")"
              );
            },
          },
        ]) && l(e.prototype, n),
        r && l(e, r),
        t
      );
    })();
    function c(t, e) {
      for (var n = 0; n < e.length; n++) {
        var r = e[n];
        (r.enumerable = r.enumerable || !1),
          (r.configurable = !0),
          "value" in r && (r.writable = !0),
          Object.defineProperty(t, r.key, r);
      }
    }
    var f = (function () {
      function t(e, n, r, i) {
        !(function (t, e) {
          if (!(t instanceof e))
            throw new TypeError("Cannot call a class as a function");
        })(this, t),
          (this.histogram = e),
          (this.colors = n),
          (this.lowerIndex = r),
          (this.upperIndex = i),
          this.fitBox();
      }
      var e, n, r;
      return (
        (e = t),
        (r = [
          {
            key: "modifySignificantOctet",
            value: function (t, e, n, r) {
              switch (e) {
                case -3:
                  break;
                case -2:
                  for (var i = n; i <= r; i++) {
                    var a = t[i];
                    t[i] = (s(a) << 10) | (o(a) << 5) | u(a);
                  }
                  break;
                case -1:
                  for (var h = n; h <= r; h++) {
                    var l = t[h];
                    t[h] = (u(l) << 10) | (s(l) << 5) | o(l);
                  }
              }
            },
          },
          {
            key: "sortRange",
            value: function (t, e, n) {
              for (var r = new Int16Array(n - e + 1), i = 0, a = e; a <= n; a++)
                (r[i] = t[a]), i++;
              r.sort(), (i = 0);
              for (var o = e; o <= n; o++) (t[o] = r[i]), i++;
            },
          },
        ]),
        (n = [
          {
            key: "getVolume",
            value: function () {
              return (
                (this.maxRed - this.minRed + 1) *
                (this.maxGreen - this.minGreen + 1) *
                (this.maxBlue - this.minBlue + 1)
              );
            },
          },
          {
            key: "canSplit",
            value: function () {
              return this.upperIndex > this.lowerIndex;
            },
          },
          {
            key: "fitBox",
            value: function () {
              (this.minRed = this.minGreen = this.minBlue = Number.MAX_VALUE),
                (this.maxRed = this.maxGreen = this.maxBlue = 0),
                (this.population = 0);
              for (var t = this.lowerIndex; t <= this.upperIndex; t++) {
                var e = this.colors[t];
                this.population += this.histogram[e];
                var n = o(e),
                  r = s(e),
                  i = u(e);
                n > this.maxRed && (this.maxRed = n),
                  n < this.minRed && (this.minRed = n),
                  r > this.maxGreen && (this.maxGreen = r),
                  r < this.minGreen && (this.minGreen = r),
                  i > this.maxBlue && (this.maxBlue = i),
                  i < this.minBlue && (this.minBlue = i);
              }
            },
          },
          {
            key: "splitBox",
            value: function () {
              if (!this.canSplit())
                throw "Can not split a box with only 1 color";
              var e = this.findSplitPoint(),
                n = new t(this.histogram, this.colors, e + 1, this.upperIndex);
              return (this.upperIndex = e), this.fitBox(), n;
            },
          },
          {
            key: "getLongestColorDimension",
            value: function () {
              var t = this.maxRed - this.minRed,
                e = this.maxGreen - this.minGreen,
                n = this.maxBlue - this.minBlue;
              return t >= e && t >= n ? -3 : e >= t && e >= n ? -2 : -1;
            },
          },
          {
            key: "findSplitPoint",
            value: function () {
              var e = this.getLongestColorDimension();
              t.modifySignificantOctet(
                this.colors,
                e,
                this.lowerIndex,
                this.upperIndex
              ),
                t.sortRange(this.colors, this.lowerIndex, this.upperIndex),
                t.modifySignificantOctet(
                  this.colors,
                  e,
                  this.lowerIndex,
                  this.upperIndex
                );
              for (
                var n = this.population / 2, r = 0, i = this.lowerIndex;
                i <= this.upperIndex;
                i++
              )
                if ((r += this.histogram[this.colors[i]]) >= n)
                  return Math.min(this.upperIndex - 1, i);
              return this.lowerIndex;
            },
          },
          {
            key: "getAverageColor",
            value: function () {
              for (
                var t = 0, e = 0, n = 0, r = 0, i = this.lowerIndex;
                i <= this.upperIndex;
                i++
              ) {
                var a = this.colors[i],
                  h = this.histogram[a];
                (r += h), (t += h * o(a)), (e += h * s(a)), (n += h * u(a));
              }
              var l = Math.round(t / r),
                c = Math.round(e / r),
                f = Math.round(n / r);
              return new g(l, c, f, r);
            },
          },
        ]) && c(e.prototype, n),
        r && c(e, r),
        t
      );
    })();
    function v(t, e) {
      if (!(t instanceof e))
        throw new TypeError("Cannot call a class as a function");
    }
    function d(t, e) {
      for (var n = 0; n < e.length; n++) {
        var r = e[n];
        (r.enumerable = r.enumerable || !1),
          (r.configurable = !0),
          "value" in r && (r.writable = !0),
          Object.defineProperty(t, r.key, r);
      }
    }
    function p(t, e, n) {
      return e && d(t.prototype, e), n && d(t, n), t;
    }
    var m = new ((function () {
        function t() {
          v(this, t),
            (this.BLACK_MAX_LIGHTNESS = 0.05),
            (this.WHITE_MIN_LIGHTNESS = 0.95);
        }
        return (
          p(t, [
            {
              key: "isAllowed",
              value: function (t) {
                var e = t[2] >= this.WHITE_MIN_LIGHTNESS,
                  n = t[2] <= this.BLACK_MAX_LIGHTNESS,
                  r = t[0] >= 10 && t[0] <= 37 && t[1] <= 0.82;
                return !e && !n && !r;
              },
            },
          ]),
          t
        );
      })())(),
      y = (function () {
        function t(e, n) {
          v(this, t);
          for (var r = new Int16Array(32768), i = 0; i < e.length; i += 4) {
            r[((e[i] >> 3) << 10) | ((e[i + 1] >> 3) << 5) | (e[i + 2] >> 3)]++;
          }
          for (var a = 0, o = 0; o < 32768; o++)
            r[o] > 0 && t.shouldIgnoreColor(o) && (r[o] = 0), r[o] > 0 && a++;
          for (var s = new Int16Array(a), u = 0, h = 0; h < 32768; h++)
            r[h] > 0 && (s[u++] = h);
          if (a <= n) {
            this.quantizedColors = new Array(a);
            for (var l = 0; l < a; l++) {
              var c = s[l],
                f = (c >> 10) & 31,
                d = (c >> 10) & 31,
                p = 31 & c;
              this.quantizedColors[l] = new g(f, d, p, r[c]);
            }
          } else this.quantizedColors = t.quantizePixels(r, s, n);
        }
        return (
          p(
            t,
            [
              {
                key: "getQuantizedColors",
                value: function () {
                  return this.quantizedColors;
                },
              },
            ],
            [
              {
                key: "quantizePixels",
                value: function (e, n, r) {
                  var a = new f(e, n, 0, n.length - 1),
                    o = new i([a], function (t, e) {
                      return e.getVolume() - t.getVolume();
                    });
                  return t.splitBoxes(o, r), t.generateAverageColors(o);
                },
              },
              {
                key: "splitBoxes",
                value: function (t, e) {
                  for (; t.length < e; ) {
                    var n = t.pop();
                    if (null == n || !n.canSplit()) break;
                    t.push(n.splitBox()), t.push(n);
                  }
                },
              },
              {
                key: "generateAverageColors",
                value: function (e) {
                  for (var n = []; e.length; ) {
                    var r = e.pop().getAverageColor();
                    t.shouldIgnoreHSL(r.getHsl()) || n.push(r);
                  }
                  return n;
                },
              },
              {
                key: "shouldIgnoreColor",
                value: function (t) {
                  var e = h(o(t) << 3, s(t) << 3, u(t) << 3);
                  return !m.isAllowed(e);
                },
              },
              {
                key: "shouldIgnoreHSL",
                value: function (t) {
                  return !m.isAllowed(t);
                },
              },
            ]
          ),
          t
        );
      })();
    function w(t, e) {
      for (var n = 0; n < e.length; n++) {
        var r = e[n];
        (r.enumerable = r.enumerable || !1),
          (r.configurable = !0),
          "value" in r && (r.writable = !0),
          Object.defineProperty(t, r.key, r);
      }
    }
    var b = 0.24,
      k = 0.52,
      x = 0.24,
      S = 0,
      T = 1,
      C = 2,
      I = 0,
      M = 1,
      B = 2,
      L = 0.26,
      _ = 0.45,
      P = 0.55,
      A = 0.74,
      G = 0.3,
      O = 0.5,
      E = 0.7,
      R = 0.3,
      j = 0.4,
      W = 1,
      F = 0.35;
    function H(t) {
      (t.lightnessTargets[T] = L), (t.lightnessTargets[C] = _);
    }
    function z(t) {
      (t.lightnessTargets[S] = G),
        (t.lightnessTargets[T] = O),
        (t.lightnessTargets[C] = E);
    }
    function D(t) {
      (t.lightnessTargets[S] = P), (t.lightnessTargets[T] = A);
    }
    function N(t) {
      (t.saturationTargets[S] = F), (t.saturationTargets[T] = W);
    }
    function V(t) {
      (t.saturationTargets[T] = R), (t.saturationTargets[C] = j);
    }
    var q = (function () {
        function t() {
          !(function (t, e) {
            if (!(t instanceof e))
              throw new TypeError("Cannot call a class as a function");
          })(this, t),
            (this.saturationTargets = [0, 0.5, 1]),
            (this.lightnessTargets = [0, 0.5, 1]),
            (this.weights = new Float32Array(3)),
            (this.weights[I] = b),
            (this.weights[M] = k),
            (this.weights[B] = x);
        }
        var e, n, r;
        return (
          (e = t),
          (n = [
            {
              key: "normalizeWeights",
              value: function () {
                for (var t = 0, e = 0, n = this.weights.length; e < n; e++) {
                  var r = this.weights[e];
                  r > 0 && (t += r);
                }
                if (0 !== t)
                  for (var i = 0, a = this.weights.length; i < a; i++)
                    this.weights[i] > 0 && (this.weights[i] /= t);
              },
            },
            {
              key: "getMinimumSaturation",
              value: function () {
                return this.saturationTargets[S];
              },
            },
            {
              key: "getTargetSaturation",
              value: function () {
                return this.saturationTargets[T];
              },
            },
            {
              key: "getMaximumSaturation",
              value: function () {
                return this.saturationTargets[C];
              },
            },
            {
              key: "getMinimumLightness",
              value: function () {
                return this.lightnessTargets[S];
              },
            },
            {
              key: "getTargetLightness",
              value: function () {
                return this.lightnessTargets[T];
              },
            },
            {
              key: "getMaximumLightness",
              value: function () {
                return this.lightnessTargets[C];
              },
            },
            {
              key: "getSaturationWeight",
              value: function () {
                return this.weights[I];
              },
            },
            {
              key: "getLightnessWeight",
              value: function () {
                return this.weights[M];
              },
            },
            {
              key: "getPopulationWeight",
              value: function () {
                return this.weights[B];
              },
            },
          ]) && w(e.prototype, n),
          r && w(e, r),
          t
        );
      })(),
      X = new q();
    D(X), N(X);
    var K = new q();
    z(K), N(K);
    var Q = new q();
    H(Q), N(Q);
    var U = new q();
    D(U), V(U);
    var J = new q();
    z(J), V(J);
    var Y = new q();
    function Z(t, e) {
      for (var n = 0; n < e.length; n++) {
        var r = e[n];
        (r.enumerable = r.enumerable || !1),
          (r.configurable = !0),
          "value" in r && (r.writable = !0),
          Object.defineProperty(t, r.key, r);
      }
    }
    H(Y),
      V(Y),
      n.d(e, "default", function () {
        return $;
      });
    new Image();
    var $ = (function () {
      function t(e, n) {
        !(function (t, e) {
          if (!(t instanceof e))
            throw new TypeError("Cannot call a class as a function");
        })(this, t),
          (this.image = e),
          (this.maxColors = n || 16);
        var r = this.image.width,
          i = this.image.height,
          a = document.createElement("canvas");
        (a.width = r), (a.height = i);
        var o = a.getContext("2d");
        o.drawImage(this.image, 0, 0);
        var s = o.getImageData(0, 0, r, i).data,
          u = new y(s, this.maxColors);
        (this.swatches = u.getQuantizedColors()),
          this.findDominantSwatch(),
          (this.targets = [X, K, Q, U, J, Y]),
          (this.usedColors = new Map()),
          (this.selectedSwatches = new Map());
        for (var h = 0; h < this.targets.length; h++) {
          var l = this.targets[h];
          l.normalizeWeights();
          var g = this.generateScoredTarget(l);
          this.selectedSwatches.set(l, g);
        }
        this.usedColors.clear();
      }
      var e, n, r;
      return (
        (e = t),
        (n = [
          {
            key: "findDominantSwatch",
            value: function () {
              var t = 0,
                e = null;
              this.swatches.forEach(function (n) {
                n.population > t && ((e = n), (t = n.population));
              }),
                (this.dominantSwatch = e);
            },
          },
          {
            key: "generateScoredTarget",
            value: function (t) {
              var e = this.getMaxScoredSwatchForTarget(t);
              return null != e && this.usedColors.set(e.rgb, !0), e;
            },
          },
          {
            key: "getMaxScoredSwatchForTarget",
            value: function (t) {
              for (var e = 0, n = null, r = 0; r < this.swatches.length; r++) {
                var i = this.swatches[r];
                if (this.shouldBeScoredForTarget(i, t)) {
                  var a = this.generateScore(i, t);
                  (a > e || null == n) && ((n = i), (e = a));
                }
              }
              return n;
            },
          },
          {
            key: "shouldBeScoredForTarget",
            value: function (t, e) {
              var n = t.getHsl(),
                r = n[1],
                i = n[2];
              return (
                r >= e.getMinimumSaturation() &&
                r <= e.getMaximumSaturation() &&
                i >= e.getMinimumLightness() &&
                i <= e.getMaximumLightness() &&
                !this.usedColors.get(t.rgb)
              );
            },
          },
          {
            key: "generateScore",
            value: function (t, e) {
              var n = 0,
                r = 0,
                i = 0,
                a = this.dominantSwatch.population,
                o = t.getHsl();
              return (
                e.getSaturationWeight() > 0 &&
                  (n =
                    e.getSaturationWeight() *
                    (1 - Math.abs(o[1] - e.getTargetSaturation()))),
                e.getLightnessWeight() > 0 &&
                  (r =
                    e.getLightnessWeight() *
                    (1 - Math.abs(o[2] - e.getTargetLightness()))),
                e.getPopulationWeight() > 0 &&
                  (i = e.getPopulationWeight() * (t.population / a)),
                n + r + i
              );
            },
          },
          {
            key: "getDominantColor",
            value: function () {
              return this.dominantSwatch.getRGB();
            },
          },
          {
            key: "getColorForTarget",
            value: function (t, e) {
              var n = this.selectedSwatches.get(t);
              return null == n ? e : n.getRGB();
            },
          },
          {
            key: "getVibrantColor",
            value: function () {
              return this.getColorForTarget(K);
            },
          },
          {
            key: "getLightVibrantColor",
            value: function () {
              return this.getColorForTarget(X);
            },
          },
          {
            key: "getDarkVibrantColor",
            value: function () {
              return this.getColorForTarget(Q);
            },
          },
          {
            key: "getMutedColor",
            value: function () {
              return this.getColorForTarget(J);
            },
          },
          {
            key: "getLightMutedColor",
            value: function () {
              return this.getColorForTarget(U);
            },
          },
          {
            key: "getDarkMutedColor",
            value: function () {
              return this.getColorForTarget(Y);
            },
          },
        ]) && Z(e.prototype, n),
        r && Z(e, r),
        t
      );
    })();
  },
]);

export default Palette
